package cp2013;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

public class HomePanel extends JPanel {

    private JButton btnRefresh;
    private JButton btnSearch;
    private JButton btnSort;
    private JButton btnPlace;
    private JButton btnRecharge;
    private JButton btnView;
    private JButton btnLogout;

    public JButton getSearchButton() {
        return btnSearch;
    }

    public JButton getSortButton(){
        return btnSort;
    }

    public JButton getPlaceObjectButton() {
        return btnPlace;
    }

    public JButton getRechargeTokenButton() {
        return btnRecharge;
    }

    public JButton getViewHistoryButton() {
        return btnView;
    }

    public JButton getLogoutButton() {
        return btnLogout;
    }

    /**
     * @return the btnRefresh
     */
    public JButton getRefreshButton() {
        return btnRefresh;
    }

    public void initiateHomePanel() {
        btnRefresh = new JButton("Refresh Items");
        btnSearch = new JButton("Search");
        btnSort = new JButton("Sort By");
        btnPlace = new JButton("Place Object");
        btnRecharge = new JButton("Recharge Token");
        btnView = new JButton("View History");
        btnLogout = new JButton("Logout");

        setLayout(new GridLayout(7, 1));
        setBackground(Color.gray);
        setBorder(new LineBorder(Color.BLACK));
        add(btnRefresh);
        add(btnSearch);
        add(btnSort);
        add(btnPlace);
        add(btnRecharge);
        add(btnView);
        add(btnLogout);
    }

    public void addHomePanelListener(ActionListener listener) {
        btnRefresh.addActionListener(listener);
        btnSearch.addActionListener(listener);
        btnSort.addActionListener(listener);
        btnPlace.addActionListener(listener);
        btnRecharge.addActionListener(listener);
        btnView.addActionListener(listener);
        btnLogout.addActionListener(listener);
    }
}
